package com.kong.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.kong.dao.RoleDao;
import com.kong.entity.PageResult;
import com.kong.entity.QueryPageBean;
import com.kong.pojo.Role;
import com.kong.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * @author yang2013
 * @data 2020/10/21 13:11
 */
@Service(interfaceClass = RoleService.class)
public class RoleServiceImpl implements RoleService {
    @Autowired
    private RoleDao roleDao;

    @Override
    public List<Role> findAll() {
        return roleDao.findAll();
    }

    @Override
    public PageResult findByPage(QueryPageBean queryPageBean) {
        PageHelper.startPage(queryPageBean.getCurrentPage(),queryPageBean.getPageSize());
        List<Role> roles=roleDao.findByPage(queryPageBean);
        PageInfo pageInfo=new PageInfo<>(roles);
        PageResult pageResult=new PageResult(pageInfo.getTotal(),roles);
        return pageResult;
    }
}
